package cn.bgs.controller;

import cn.bgs.pojo.CellIntermediate;
import cn.bgs.pojo.UserVo;
import cn.bgs.service.CellService;
import cn.bgs.utils.R;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("cell")
public class CellController {
    @Autowired
    private CellService cellService;
    @GetMapping("findcell")
    public PageInfo<CellIntermediate> findcell(String  communityId,String state ,String identity,Integer pagesize,Integer pagenow){
        PageInfo<CellIntermediate> cells =cellService.findcell(communityId,state,identity,pagesize,pagenow);
        return cells;
    }
    @GetMapping("del")
    public R del(Integer id){
        cellService.del(id);
        return R.ok();
    }
    @PostMapping("load")
    public R load(Integer id){
        List<CellIntermediate> cellIntermediate = cellService.load(id);
        return R.ok().data("data",cellIntermediate);
    }
    @PostMapping("adduser")
    public R adduser(@RequestBody UserVo forms){
        cellService.adduser(forms);
        return R.ok();
    }
    @PostMapping("updatestate")
    public  R updatestate (@RequestBody CellIntermediate forms){
        cellService.updatestate(forms);
        return R.ok();
    }
}